Passed
Pull Request — master (#70)
by Mathieu
01:22
created

Quote   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 52
dl 0
loc 56
c 0
b 0
f 0
rs 10

2 Functions

Rating   Name   Duplication   Size   Complexity  
A getAvailableStatus 0 8 1
A getId 0 3 1
1
import {Entity, Column, PrimaryGeneratedColumn, ManyToOne} from 'typeorm';
2
import {Customer} from '../Customer/Customer.entity';
3
import {Project} from '../Project/Project.entity';
4
import {User} from '../User/User.entity';
5
6
@Entity()
7
export class Quote {
8
  public static readonly STATUS_DRAFT = 'draft';
9
  public static readonly STATUS_SENT = 'sent';
10
  public static readonly STATUS_REFUSED = 'refused';
11
  public static readonly STATUS_ACCEPTED = 'accepted';
12
  public static readonly STATUS_CANCELED = 'canceled';
13
14
  public static getAvailableStatus(): string[] {
15
    return [
16
      Quote.STATUS_DRAFT,
17
      Quote.STATUS_SENT,
18
      Quote.STATUS_REFUSED,
19
      Quote.STATUS_ACCEPTED,
20
      Quote.STATUS_CANCELED
21
    ];
22
  }
23
24
  @PrimaryGeneratedColumn('uuid')
25
  private id: string;
26
27
  @Column({type: 'varchar', nullable: false})
28
  private status: string;
29
30
  @Column({type: 'varchar', nullable: false, unique: true})
31
  private quoteId: string;
32
33
  @Column({type: 'timestamp', default: () => 'CURRENT_TIMESTAMP'})
34
  private createdAt: Date;
35
36
  @ManyToOne(type => User, {nullable: false})
37
  private owner: User;
38
39
  @ManyToOne(type => Customer, {nullable: false})
40
  private customer: Customer;
41
42
  @ManyToOne(type => Project, {nullable: true})
43
  private project: Project;
44
45
  constructor(
46
    quoteId: string,
47
    status: string,
48
    owner: User,
49
    customer: Customer,
50
    project?: Project | null
51
  ) {
52
    this.quoteId = quoteId;
53
    this.status = status;
54
    this.owner = owner;
55
    this.customer = customer;
56
    this.project = project;
57
  }
58
59
  public getId(): string {
60
    return this.id;
61
  }
62
}
63